<?php

namespace LaiHe\LaravelHelper\Auth;

use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Hash;
use LaiHe\LaravelHelper\Eloquent\Model as BaseModel;
use Tymon\JWTAuth\Contracts\JWTSubject;

class Model extends BaseModel implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, JWTSubject
{
	use Notifiable, Authenticatable, Authorizable, CanResetPassword;

	protected $hidden = ['password', 'remember_token'];

	/**
	 * 加密密码
	 *
	 * @param string $value
	 */
	protected function setPasswordAttribute($value)
	{
		$this->attributes['password'] = Hash::createBcryptDriver()->make($value);
	}

	/**
	 * @inheritDoc
	 */
	public function getJWTIdentifier()
	{
		return $this->getkey();
	}

	/**
	 * @inheritDoc
	 */
	public function getJWTCustomClaims()
	{
		return [];
	}
}
